<?php
//判断是否存在，存在赋值$_GET["name"] 反之''
    $name = isset($_POST["name"]) ? $_POST["name"] : '';
    //echo $name;
    include './public/db_object.php';
    $db = new DB_object(['db_name'=> 'db_shop']);
//%$_POST[name]%
   $sql = "select * from t_goods where gname like'%$name%'";

if($result=$db->l_query($sql))
{
    
    // 一行行获取
    while ($row=mysqli_fetch_assoc($result))
    {
        // echo '<pre>';
        // var_dump($row);
        // printf('%s %s %s',$row['gname'],$row['price'],$row['thumb']);
        // echo "</br>";
        $data_arr[] = $row;
    }
    mysqli_free_result($result);
}
// echo '<pre>';
// var_dump();
echo json_encode($data_arr);
//echo json_encode($data_arr);

?>